package encore.portal.portlet.filter;

import java.util.Enumeration;
import java.util.List;
import java.util.Vector;

import javax.portlet.PortletContext;
import javax.portlet.filter.FilterConfig;

import encore.portal.portlet.models.InitParam;

public class FilterConfigImpl implements FilterConfig {

	private final String filterName;
	private final List<? extends InitParam> initParameters;
	private final PortletContext portletContext;
	
	public FilterConfigImpl(String filterName,List<? extends InitParam> initParams,PortletContext portletContext)
	{
		this.filterName=filterName;
		this.initParameters=initParams;
		this.portletContext=portletContext;	
	}
	
	
	
	@Override
	public String getFilterName() {
		// TODO Auto-generated method stub
	  return this.filterName;
	}

	@Override
	public String getInitParameter(String name) {
		if(initParameters!=null)
		{
			for(InitParam initParam:initParameters)
			{
				if(initParam.getParamName().equals(name))
				{
					return initParam.getParamValue();
				}
			}
		}
		return null;
	}

	@Override
	public Enumeration<String> getInitParameterNames() {
		Vector<String> enuml=new Vector<String>();
		if(initParameters!=null)
		{
			for(InitParam initParam:initParameters)
			{
				enuml.add(initParam.getParamName());
			}
		}
		return enuml.elements();
	}

	@Override
	public PortletContext getPortletContext() {

		return portletContext;
	}

}
